﻿using LeekGPTApp.Library.Services;
using LeekGPTApp.Library.ViewModels;
using SemanticKernelBlazorDemo.Shared.Services;

namespace LeekGPTApp;
public class ServiceLocator
{
    private IServiceProvider _serviceProvider;

    public MainPageViewModel MainPageViewModel =>
        _serviceProvider.GetService<MainPageViewModel>(); //依赖注入

    public ServiceLocator()
    {
        var serviceCollection = new ServiceCollection();

        serviceCollection.AddSingleton<MainPageViewModel>();

        serviceCollection
            .AddSingleton<IJudgeKeyService, JudgeKeyService>();
        serviceCollection
            .AddSingleton<ISelectKeyService, SelectKeyService>();
        serviceCollection
            .AddSingleton<IEvaluateService, EvaluateService>();
        serviceCollection
            .AddSingleton<IGPTEvaluateService, GPTEvaluateService>();
        serviceCollection
            .AddSingleton<IHtmlInfoService, HtmlInfoService>();
        serviceCollection
            .AddSingleton<IKernelFactory, KernelFactory>();
        serviceCollection
            .AddSingleton<IFundInfo, FundInfoService>();


        _serviceProvider = serviceCollection.BuildServiceProvider();

    }
}
